package com.zl.model;

import javax.persistence.*;

/**
 * User: c3t
 * Date: 13-10-17
 * Time: 下午12:30
 */
@Entity
@Table(name="t_user_msg")
public class UserMessage {
	private int id;
	private User user;
	private Message message;
	private int isRead;
	private int type;

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		UserMessage that = (UserMessage) o;

		if (!message.equals(that.message)) return false;
		if (!user.equals(that.user)) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = user.hashCode();
		result = 31 * result + message.hashCode();
		return result;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="user_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne
	@JoinColumn(name="msg_id")
	public Message getMessage() {
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	/**
	 * 是否是已读
	 * @return
	 */
	@Column(name="is_read")
	public int getRead() {
		return isRead;
	}

	public void setRead(int read) {
		isRead = read;
	}

	/**
	 * 私人信件是发送还是接收的
	 * @return
	 */
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
}
